package tr.hba.jblog.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import tr.hba.jblog.dao.IUserDAO;
import tr.hba.jblog.model.User;

@Service("userService")
public class UserService implements IUserService {
	
	private IUserDAO entityDAO;

	@Autowired
	public UserService(IUserDAO entityDAO) {
		this.entityDAO = entityDAO;
	}

	@Transactional
	public void create(User entity) {
		entityDAO.create(entity);
		
	}

	@Transactional
	public void delete(User entity) {
		entityDAO.delete(entity);
		
	}

	@Transactional(readOnly = true)
	public List<User> findAll() {
		return entityDAO.loadAll();
	}

	@Transactional(readOnly = true)
	public User findById(Long id) {
		return entityDAO.loadById(id);
	}

	@Transactional
	public void update(User entity) {
		entityDAO.update(entity);
		
	}

}
